import React, { useReducer } from 'react'

import GlobalContext from './Context'
import { reducer, initialState } from './reducer'

import Child1 from './Child1'
import Child2 from './Child2'
import Child3 from './Child3'

export default function App() {
  // 每次定义，都是一个全新的
  const [state, dispatch] = useReducer(reducer, initialState)
  return (
    <GlobalContext.Provider
      value={{
        state,
        dispatch,
      }}
    >
      <div>
        <h1>App</h1>
        <Child1></Child1>
        <Child2></Child2>
        <Child3></Child3>
      </div>
    </GlobalContext.Provider>
  )
}
